home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 15 / CU Amiga Magazine's Super CD-ROM 15 (1997)(EMAP Images)(GB)[!][issue 1997-10].iso / CUCD / Graphics / Ghostscript / source / pdf2dsc.ps < prev    next >
Encoding:
Text File  |  1996-09-21  |  3.4 KB  |  104 lines

  1. %    Copyright (C) 1994, 1995, 1996 Aladdin Enterprises.  All rights reserved.
  2. % This file is part of Aladdin Ghostscript.
  3. % Aladdin Ghostscript is distributed with NO WARRANTY OF ANY KIND.  No author
  4. % or distributor accepts any responsibility for the consequences of using it,
  5. % or for whether it serves any particular purpose or works at all, unless he
  6. % or she says so in writing.  Refer to the Aladdin Ghostscript Free Public
  7. % License (the "License") for full details.
  8. % Every copy of Aladdin Ghostscript must include a copy of the License,
  9. % normally in a plain ASCII text file named PUBLIC.  The License grants you
  10. % the right to copy, modify and redistribute Aladdin Ghostscript, but only
  11. % under certain conditions described in the License.  Among other things, the
  12. % License requires that the copyright notice and this notice be preserved on
  13. % all copies.
  14.  
  15. % pdf2dsc.ps
  16. % read pdf file and produce DSC "index" file.
  17. %
  18. % Input  file is named PDFname
  19. % Output file is named DSCname
  20. %
  21. % Run using:
  22. %  gs -dNODISPLAY -sPDFname=pdffilename -sDSCname=tempfilename pdf2dsc.ps
  23. % Then display the PDF file with
  24. %  gs tempfilename
  25. %
  26. % Modified by rjl/lpd 9/19/96
  27. %    Updates for compatibility with modified pdf_*.ps code for handling
  28. %      page ranges (i.e., partial files) better.
  29. % Modified by Geoff Keating <Geoff.Keating@anu.edu.au> 7/3/96:
  30. %    include Title and CreationDate DSC comments (these are displayed by
  31. %      Ghostview);
  32. %    reduce the size of typical output files by a factor of about 3.
  33. % Modified by L. Peter Deutsch 3/18/96:
  34. %    Removes unnecessary and error-prone code duplicated from pdf_main.ps
  35. % Modified by L. Peter Deutsch for GS 3.33
  36. % Originally by Russell Lang  1995-04-26
  37.  
  38. /DSCfile DSCname (w) file def
  39. /DSCstring 255 string def
  40.    GS_PDF_ProcSet begin
  41.    pdfdict begin
  42.    PDFname (r) file
  43.    pdfopen begin
  44. % setup for loop  (init increment limit)
  45.    /FirstPage where { pop FirstPage } { 1 } ifelse
  46.    1
  47.    /LastPage where { pop LastPage } { pdfpagecount } ifelse
  48. % write header and prolog
  49. DSCfile (%!PS-Adobe-3.0\n) writestring
  50. Trailer /Info knownoget
  51.  {
  52.    dup /Title knownoget
  53.     {
  54.       DSCfile (%%Title: ) writestring
  55.       DSCfile exch write==
  56.     }
  57.    if
  58.    /CreationDate knownoget
  59.     {
  60.       DSCfile (%%CreationDate: ) writestring
  61.       DSCfile exch write==
  62.     }
  63.    if
  64.  }
  65. if
  66. DSCfile (%%Pages: ) writestring
  67. DSCfile 1 index 3 index sub 1 add DSCstring cvs writestring
  68. DSCfile (\n%%EndComments\n) writestring
  69. DSCfile (%%BeginProlog\n) writestring
  70. DSCfile (/Page null def\n/Page# 0 def\n/PDFSave null def\n/DSCPageCount 0 def\n) writestring
  71. DSCfile (/DoPDFPage {dup /Page# exch store pdfgetpage pdfshowpage } def\n) writestring
  72. DSCfile (GS_PDF_ProcSet begin\npdfdict begin\n) writestring
  73. DSCfile (%%EndProlog\n) writestring
  74. DSCfile (%%BeginSetup\n) writestring
  75. DSCfile PDFname write==only
  76. DSCfile ( \(r\) file pdfopen begin\n) writestring
  77. DSCfile (%%EndSetup\n) writestring
  78. % process each page
  79.     {
  80. DSCfile (%%Page: ) writestring
  81. DSCfile 1 index DSCstring cvs writestring
  82. DSCfile ( ) writestring
  83. DSCfile 1 index DSCstring cvs writestring
  84. DSCfile (\n) writestring
  85. DSCfile exch DSCstring cvs writestring
  86. DSCfile ( DoPDFPage\n) writestring
  87.     } for
  88.    currentdict pdfclose
  89.    end
  90.    end
  91.    end
  92. % write trailer
  93. DSCfile (%%Trailer\n) writestring
  94. DSCfile (currentdict pdfclose\nend\nend\nend\n) writestring
  95. DSCfile (%%EOF\n) writestring
  96. % close output file and exit
  97. DSCfile closefile
  98. quit
  99. % end of pdf2dsc.ps
  100.  
  101.